What are the requirements to test a website using jquery.get() ? [migrated]
Posted
by
Frankie
on Pro Webmasters
See other posts from Pro Webmasters
or by Frankie
Published on 2011-04-10T00:14:43Z
Indexed on
2011/06/20
16:39 UTC
Read the original article
Hit count: 287
I am working on a simple website. It has to search quite a few text files in different sub-folders. The rest of the page uses jquery, so I would like to use it for this also. The function I am looking at is .get() for downloading the files. So my main question is, can I test this on my local computer (Ubuntu Linux) or do I have to have it uploaded to a server?
Also, if there's a better way to go about this, that would be nice to know. However, I'm more worried about getting it working.
Thanks, Frankie
PS: Heres the JS/jQuery code for downloading the files to an array.
g_lists = new Array();
$(":checkbox").each(function(i){
if ($(this).attr("name") != "0")
{
var path = "../" + $(this).attr("name") + ".txt";
$("#bot").append("<br />" + path); // debug
$.get(path, function(data){
g_lists[i] = data;
$("#bot").html(data);
});
}
else
{
g_lists[i] = "";
}
});
Edit: Just a note about the path variable. I think it's correct, but I'm not 100% sure. I'm new to web development. Here's some examples it produces and the directory tree of the site. Maybe it will help, can't hurt.
.
+-- include
¦ +-- jquery.js
¦ +-- load.js
+-- index.xhtml
+-- style.css
+-- txt
+-- Scripting_Tools
+-- Editors.txt
+-- Other.txt
Examples of path:
../txt/Scripting_Tools/Editors.txt
../txt/Scripting_Tools/Other.txt
Well I'm a new user, so I can't "answer" my own question, so I'll just post it here:
After asking for help on a IRC chat channel specific to jQuery, I was told I could use this on a local host. To do this I installed Apache web server, and copied my site into it's directory. More information on setting it up can be found here: http://www.howtoforge.com/ubuntu_debian_lamp_server
Then to run the site I navigated my browser to "localhost" and everything works.
© Pro Webmasters or respective owner